﻿#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:1073741824") //谨防空间不够
#include "data.h"
using namespace std;
constexpr auto RanDomString = "AIIOmH5qyF9x22wRQHawdaXERkX6QFDv5Um4T5YNsBKqZa6xG2pbOIKSSBw4StHIRp7ZDM6N1px14AHx44Pq2V2L4Gyx3SYF0w4NAk5MC0UuShlRaVFpHDhstXDJyaf";
int main()
{
    string n = RanDomString;
    cout << "\"欢迎语\"" << endl;
    OutputLoading();
    cout << endl;
    PullUsernameHere("root");//需要先校验root用户的存在性
    if (CheckFileExist())
        n = CreatNewUser();
    else
    {
        cout << "1.登录 2.创建用户\n";
        int cos; cin >> cos;
        if (cos == 2)
            CreatNewUser();
        else
           CleanOutput() ;
    }
    string username;//username should used to set the file name but not in any data deal!
  //  if (n == (RanDomString)) //要指定用户名喵
    {
        cout << "请输入用户名：";
        cin >> username;
        cout << "please input password: ";
        cin >> n;
        n = AddSalt(n);
    }
    if (!Login(username,n))
        FailToLogin();
    else
        LoginSuccessd(n);
    {
    func:
        CleanOutput();
        int res = MainFunction();
        if (res == 1)
        {
            goto func;
        }
        else if (res == 0)
        {
            cout << "输入错误！请重新输入" << endl;
            system("pause");
            CleanOutput();
            goto func;
        }
    }
    {
        QuitProgram(n);
    }
    return 0;
}